/* 
    WhaleSpotter
    Copyright (C) 2007  Bob Mottram
    fuzzgun@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace whalespotter
{
    public class settings
    {
        public int RecognitionThreshold = 50;
        public float weight_key_features = 1.0f;
        public float weight_linear_features = 1.0f;
        public float weight_edge_pattern = 1.0f;
        public String camera_drive = "C:\\whalespotter\\sightings";

        public void Save(String filename)
        {
            FileStream fp = new FileStream(filename, FileMode.Create);
            BinaryWriter binfile = new BinaryWriter(fp);

            binfile.Write(RecognitionThreshold);
            binfile.Write(weight_key_features);
            binfile.Write(weight_linear_features);
            binfile.Write(weight_edge_pattern);
            binfile.Write(camera_drive);

            binfile.Close();
            fp.Close();
        }

        public void Load(String filename)
        {
            if (File.Exists(filename))
            {
                FileStream fp = new FileStream(filename, FileMode.Open);
                BinaryReader binfile = new BinaryReader(fp);

                try
                {
                    RecognitionThreshold = binfile.ReadInt32();
                    weight_key_features = binfile.ReadSingle();
                    weight_linear_features = binfile.ReadSingle();
                    weight_edge_pattern = binfile.ReadSingle();
                    camera_drive = binfile.ReadString();
                }
                catch
                {
                }

                binfile.Close();
                fp.Close();
            }
        }
    }
}
